package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.AnswerSheet;

@Repository
public interface AnswerSheetDao extends JpaRepository<AnswerSheet, Integer>, JpaSpecificationExecutor<AnswerSheet> {

	@Query("from AnswerSheet where studentAndExam_id = ?1")
	List<AnswerSheet> find(String name);

	@Query("from AnswerSheet where studentAndExam_id like ?1")
	List<AnswerSheet> findLike(String name);

	@Query(value = "select * from AnswerSheet limit ?, ?", nativeQuery = true)
	List<AnswerSheet> findPage(Integer offset, Integer size);

	@Query(value = "select * from AnswerSheet where studentAndExam_id = ? limit ?, ?", nativeQuery = true)
	List<AnswerSheet> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from AnswerSheet where studentAndExam_id like ? limit ?, ?", nativeQuery = true)
	List<AnswerSheet> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from AnswerSheet where studentAndExam_id = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from AnswerSheet where studentAndExam_id like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from AnswerSheet order by id asc")
	List<AnswerSheet> findAllAsc();
}

